package com.session05;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class TestCopy {
    public static void main(String[] args) {
        try (FileInputStream fin = new FileInputStream("shiqi.jpg");
             FileOutputStream fout = new FileOutputStream("D:/AAAA/shiqikuangsan.jpg")) {

            //极其重要
            byte[] bytes = new byte[1024];
            int length = 0;
            while ((length = fin.read(bytes)) != -1) {
                fout.write(bytes, 0, length);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
